import { useRef,useState } from "react";
export default function App() {
    const [count, setCount] = useState(0)
    const timer = useRef<number | null>(null)
    const handleClick = () => {
        setCount(count + 1)
        if (timer.current) {
            clearInterval(timer.current)
        }
        timer.current = setInterval(() => {
            console.log('********');
        },1000)
    }
    return (
        <>
            <h1>Ref Components</h1>
            <button onClick={handleClick}>++++++</button>
            <br />
            {count}
        </>
    );
}